﻿<UserControl x:Class="Songhay.Silverlight.BiggestBox.IndexPart.Views.UserControls.NetflixSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:m="clr-namespace:Songhay.Silverlight.BiggestBox.IndexPart.ViewModels"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    Tag="Netflix OData Sample"
    Width="512" Height="300">
    <UserControl.Resources>
        <m:NetflixViewModel x:Key="NetflixViewModelDataSource" d:IsDataSource="True" />
        <!--
            Based on Silverlight 4 Netflix Browser
            [http://silverlight4netflix.codeplex.com/]
        -->
        <Style TargetType="ListBox">
            <Setter Property="Background" Value="#FFFF0008" />
        </Style>
        <DataTemplate x:Key="GenreItems">
            <StackPanel>
                <TextBlock Text="{Binding Name}" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="TitleItems">
            <StackPanel Orientation="Horizontal">
                <Image Margin="0,0,8,0" Source="{Binding BoxArt.SmallUrl}" />
                <StackPanel>
                    <TextBlock Text="{Binding Name}" FontSize="12" FontWeight="Bold" TextWrapping="Wrap" />
                    <TextBlock Text="{Binding Rating, StringFormat='Rated {0}'}" />
                    <TextBlock Text="{Binding ReleaseYear, StringFormat='Released in {0}'}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <toolkit:DockPanel
        DataContext="{StaticResource NetflixViewModelDataSource}"
        LastChildFill="True">
        <StackPanel toolkit:DockPanel.Dock="Left"
            Width="160">
            <Image
                Source="/Songhay.Silverlight.BiggestBox.IndexPart;Component/Bitmaps/NetflixLogo.png"
                />
            <toolkit:BusyIndicator IsBusy="{Binding IsLoadingGenres}">
                <ListBox
                    Background="Transparent"
                    BorderThickness="0"
                    Height="229"
                    ItemsSource="{Binding Path=NetflixGenres}"
                    ItemTemplate="{StaticResource GenreItems}"
                    SelectedItem="{Binding Path=NetflixSelectedGenre, Mode=TwoWay}"
                    />
            </toolkit:BusyIndicator>
        </StackPanel>
        <toolkit:BusyIndicator toolkit:DockPanel.Dock="Right"
            IsBusy="{Binding IsLoadingTitles}">
            <ListBox
                ItemsSource="{Binding Path=NetflixTitles}"
                ItemTemplate="{StaticResource TitleItems}"
                />
        </toolkit:BusyIndicator>
    </toolkit:DockPanel>
</UserControl>
